<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="author" content="ISUX">
    <meta name="format-detection" content="telephone=no"/>
    <meta name="layout" content="main_mobile">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<script type="text/javascript" src="${resource(dir: 'js', file: 'jquery-1.10.2.js')}" ></script>
    <link rel="stylesheet" type="text/css" href="../frozen/css/frozen.css">
    <link rel="stylesheet" type="text/css" href="../css/default.css">
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>	
 <link rel="stylesheet" type="text/css" href="../css/fund_pool.css">
    <title>${fundpool.name}爱心池</title>
   
  
</head>
<body>


<input type="hidden"  id="descriptionTip" value="${fundpool?.description}"/>
<input type="hidden"  id="nameTip" value="${fundpool?.name}"/>
<script type="text/javascript">

	wx.config({
 	    debug: false,  // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
 	    appId: '${appid}', // 必填，公众号的唯一标识
 	    timestamp: "${timestamp}", // 必填，生成签名的时间戳
 	    nonceStr: '${nonceStr}', // 必填，生成签名的随机串
 	    signature: '${signature}',// 必填，签名，见附录1
 	    jsApiList: ['checkJsApi' , 'onMenuShareAppMessage' , 'onMenuShareTimeline']
 	});

 	wx.ready(function(){
 		wx.checkJsApi({
 		    jsApiList: ['onMenuShareAppMessage' , 'onMenuShareTimeline'], // 需要检测的JS接口列表，所有JS接口列表见附录2,
 		    success: function(res) {
 		       //alert('wx.check: '+JSON.stringify(res));
 		    }
 		});
 		//发送给朋友分享功能
 		wx.onMenuShareAppMessage({
 		    title: $("#nameTip").val()+'爱心池，为爱加分-火堆公益', // 分享标题
 		    desc: $("#descriptionTip").val(), // 分享描述
 		    link: '${url}', // 分享链接
 		    imgUrl: '${imgUrl}', // 分享图标
			trigger: function () {
			//alert("点击按钮");
			},
 		    success: function () { 
 		        // 用户确认分享后执行的回调函数
 		    },
 		    cancel: function () { 
 		        // 用户取消分享后执行的回调函数
 		    }
 		});

 		//分享到朋友圈
 		wx.onMenuShareTimeline({
 		    title: $("#nameTip").val()+'爱心池，为爱加分-火堆公益', // 分享标题
 		    link: '${url}', // 分享链接
 		    imgUrl: '${imgUrl}',  // 分享图标
 		    success: function () { 
 		        // 用户确认分享后执行的回调函数
 		    },	
 		    cancel: function () { 
 		        // 用户取消分享后执行的回调函数
 		    }
 		});

 	});
 	wx.error(function (res) {
		//alert('wx.error: '+JSON.stringify(res));
    });
	</script>
<%--
    <div class="ui-footer ui-footer-navi ui-btn-group ui-border-t">
        <a href="/scfire" ><i class="i1"></i><div>首页</div></a>
        <a href="/scfire/project/fundPoolList" class="active"><i class="i2"></i><div>爱心池</div></a>
        <a href="/scfire/project/start"><i class="i3"></i><div>发起项目</div></a>
        <a href="/scfire/user/userCenter" ><i class="i4"></i><div>个人中心</div></a>
    </div>

    --%><section class="ui-container">
        <div class="fp-detail-top ui-border-b">
            <ul class="ui-list fb-list">
                <li class="ui-border-t">
                    <a href="#">
                        <div class="ui-list-img">
                            <span style="background-image:url(/scfire/project/imgRead?img=${fundpool.coverPic})">
                                <span>${fundpool.type}</span>
                            </span>
                        </div>
                        <div class="ui-list-info">
                            <h4 class="ui-nowrap">${fundpool.name}</h4>
                            <p>${fundpool.description}</p>
                        </div>
                    </a>
                </li>
            </ul>
        </div>

        <ul class="ui-tiled ui-info-tiled ui-border-b">
            <li>
                <div class="num"><em>${total_times}</em>人次</div>
                <div>累计助力</div>
            </li>
            <li>
                <div class="num"><em><g:formatNumber number="${fundpool?.donateActual/100}" format="0.00"/></em>元</div>
                <div>累计配捐</div>
            </li>
            <li>
                <div class="num"><em><g:formatNumber number="${fundpool.totalCount/100- fundpool.donateActual/100}" format="0.00"/></em>元</div>
                <div>配捐余额</div>
            </li>
        </ul>
    
        <div class="ui-card-module ui-border-tb">
            <h4 class="ui-border-b">配捐项目（${totalProject}）</h4>            
            <ul class="p-list" id="append"><%--
              <g:each in="${fRules}" var="${fRule}">
                <li>  
                    <a href="/scfire/project/donatematchDetail?projectid=${fRule?.project.id}&fundPoolid=${fundpool.id}">
                         <div class="top" style="background-image:url(/scfire/project/imgRead?img=${fRule?.project.img})">
                            <div class="h3-box"><h3>${fRule?.project.name}</h3></div>
                            <div class="ui-progress">
                                <span style="width:${fRule?.project.progress}%"></span>
                            </div>
		                <g:if test="${fRule?.project.verified=='pass'}">x
		                	<div class="status">募集中</div>
		                </g:if>                
		                <g:elseif test="${fRule?.project.verified=='execute'}">
		                	<div class="status yellow">已筹满</div>
		                </g:elseif>
		                <g:elseif test="${fRule?.project.verified=='expired'}">
		                	<div class="status">已过期</div>
		                </g:elseif>
		                <g:elseif test="${fRule?.project.verified=='over'}">
		                	<div class="status">已结束</div>
		                </g:elseif>
                        </div>
                        <div class="bottom">
                            <div class="infos">
                                <div class="infos-l">共<span class="num">${fRule?.project?.donates.size()}</span>份爱心捐款</div>
                                <div class="infos-r">已筹<span class="num"><g:formatNumber number="${fRule?.project.amount - fRule?.project.rest}" format="0.00"/></span>元</div>
                            </div>
                        </div>
                    </a>
                </li>
                </g:each>
            --%></ul>
        </div>

        <div class="ui-line-more" id="more">
             <p  id='week'>加载完成</p>
        </div>

<%--        <div class="banner-wrap">--%>
<%--            <div class="txt-bottom">--%>
<%--            <a href="http://mp.weixin.qq.com/mp/homepage?__biz=MzAxNjM5NzExOQ==&hid=3&sn=e498fbdd2e826943340c0729061ac868#wechat_redirect">了解火堆</a>--%>
<%--            <a href="/scfire/project/qrcode">关注火堆</a><img src="../images/ic-qrcode.png" alt="">--%>
<%--            </div>--%>
<%--            <img class="img-bottom" src="../images/logo_and_txt.png" alt="">--%>
<%--        </div>--%>
    </section>

    <script src="../frozen/lib/zeptojs/zepto.min.js"></script>
    <script src="../frozen/js/frozen.js"></script>
    
    <script>
    var finalOffset=20
	var offset = 0
	ajaxRead(); 
    function ajaxRead()  
    {  
	  
        var html="";  
        $.ajax({  
              type:'get',  
              dataType:'json',
	          url:'/scfire/project/fundpooldetail?format=json&offset='+offset+"&fundPoolid="+${fundpool.id},  
              beforeSend:function(){console.log('loading...');$("#week").html('加载中...');},  
              success:function(data){
      	  			$.each(data,function(i,item){
      	  			offset++                   
                html += "<li><a href='/scfire/project/donatematchDetail?projectid="+item.projectid+"&fundPoolid=${fundpool.id}'>"
            	html += "<div class='top' style='background-image:url(/scfire/project/imgRead?img="+item.img+")'>"
            	html += "<div class='h3-box'><h3>"+item.name+"</h3></div>"
                html +="<div class='ui-progress'>"
                html +="<span style='width:"+item.progress+"%'></span>"
                html +="</div>"

    	        if(item.verified == 'pass'){
    	        	html +="<div class='status'>募集中</div>"
        	    }   
    	        else if(item.verified == 'execute'||item.verified == 'expired'){
    	        	html +="<div class='status yellow'>已筹完</div>"
        	    }
    	        else if(item.verified == 'over'){
    	        	html +="<div class='status'>已结项</div>"
        	    }else if(item.verified == 'doing'){
    	        	html +="<div class='status'>执行中</div>"
        	    }      	

        	  
                    
                html +="</div>"
                html +="<div class='bottom'>"
                html +="<div class='infos'>"
                	 html +="<div class='infos-l'>助力<span class='num'>"+item.donatessize+"</span>份爱心</div>"
                	 html +="<div class='infos-r'>已配捐<span class='num'>"+item.savemoney.toFixed(2)+"</span>元</div>"
                html +="</div>"
               
                html +="</div>"
                html +="</li>"

              });
				$("#append").append(html);
               if(data.length<finalOffset){       				
 				$("#week").html("已经到底了")
 				$("#week").removeAttr("onclick");
 				
     		}else{
     			
	            $("#week").html("加载更多")
	            $("#week").attr("onclick","ajaxRead()");
         		}
              },  
              complete:function(){console.log('mission complete.')}  ,
              error:function(data){
                
            	  console.log("error")
            	  $("#week").html('已经到底了');
              }
  
        });  
    }  

    </script>
</body>
</html>